#!/usr/bin/env python

def _(s): return s

import os, sys, wx

class SaveAs:
    def __init__(self, mainWin):
        wildcard = "All files (*.*)|*.*|"\
                   "Apache config (*.conf)|*.conf"
        file = "apache2.conf"
        dlg = wx.FileDialog(mainWin, message=_("Save file as ..."),
                            defaultDir=os.getcwd(), defaultFile=file,
                            wildcard=wildcard, style=wx.SAVE)
        dlg.SetFilterIndex(1)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            try:
                mainWin.myapache.save_config(path)
                mainWin.fileSaved = True
                mainWin.SetStatusText(_("Succesfully saved: %s") % path)
                mainWin.currentFile = path
                mainWin.SetTitle(path)
                mainWin.userSettings.updateHistory(path)
                mainWin.fileHist.AddFileToHistory(path)
            except (OSError, IOError), err:
                UserMessage.say(err, _("Error!"), wx.ICON_ERROR)
